/*
 Navicat MySQL Data Transfer

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Server Version : 80012
 Source Host           : 127.0.0.1:3306
 Source Schema         : blog

 Target Server Type    : MySQL
 Target Server Version : 80012
 File Encoding         : 65001

 Date: 05/12/2018 19:52:14
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for admins
-- ----------------------------
DROP TABLE IF EXISTS `admins`;
CREATE TABLE `admins` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `staff_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '員工編號',
  `password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '密碼',
  `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名字',
  `nickname` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '暱稱',
  `avatar` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '頭像',
  `call_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '分機號',
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '郵箱',
  `enable` tinyint(1) NOT NULL DEFAULT '1' COMMENT '啟用狀態',
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `admins_staff_id_unique` (`staff_id`)
) ENGINE=InnoDB AUTO_INCREMENT=122 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of admins
-- ----------------------------
BEGIN;
INSERT INTO `admins` VALUES (1, 10400, '$2y$10$.pJmemzE.VCdZHnYuCKlF.//J7i9a5WGap9wAzKqXaNtJjaJV8ri.', 'HDJ', 'Deeka', '', '', '', 1, NULL, '2018-11-30 07:39:03', '2018-11-30 07:39:03');
INSERT INTO `admins` VALUES (2, 10614, '$2y$10$UD1dlqwIwqbOn8dHCd7bxu0jLRhKmhA6OyGhCo8ZZBjWtYBJ4b6UG', 'LinJi', 'JJ', '', '0', '0', 1, NULL, '2018-11-30 07:39:03', '2018-12-03 07:11:52');
INSERT INTO `admins` VALUES (3, 10702, '$2y$10$G8jQekx6mJEoE/GOswiFcOKskBP4VYHMIgRFbVpLQ4Y3Pf9iSpXvO', '廖海波', '廖海波', '', '0', '0', 1, '4IqDExrglYWYKzFtT9uywILr5pCHQxNztK8WydxyO4z0mHxVbOihbXsDSA4e', '2018-11-30 07:39:03', '2018-12-03 07:10:08');
INSERT INTO `admins` VALUES (4, 10709, '$2y$10$W1BfRvx9Mdr4MT1OBAL5au6eMoe004kk7Nr2iFGHzlIJ2J.q18NtW', 'FC', 'FC', '', '', '', 1, 'rJ4URVpYg2djKBcmZSupLt2j7eTblKJrDaNnEeNDBYoDIN6cfe14AysIC7c1', '2018-11-30 07:39:03', '2018-12-04 10:17:14');
COMMIT;

-- ----------------------------
-- Table structure for migrations
-- ----------------------------
DROP TABLE IF EXISTS `migrations`;
CREATE TABLE `migrations` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of migrations
-- ----------------------------
BEGIN;
INSERT INTO `migrations` VALUES (17, '2018_07_31_075703_create_permission_tables', 1);
INSERT INTO `migrations` VALUES (20, '2018_07_31_081617_create_admins_table', 2);
INSERT INTO `migrations` VALUES (21, '2018_11_29_082507_create_users_table', 3);
COMMIT;

-- ----------------------------
-- Table structure for model_has_permissions
-- ----------------------------
DROP TABLE IF EXISTS `model_has_permissions`;
CREATE TABLE `model_has_permissions` (
  `permission_id` int(10) unsigned NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  KEY `model_has_permissions_model_type_model_id_index` (`model_type`,`model_id`),
  CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Table structure for model_has_roles
-- ----------------------------
DROP TABLE IF EXISTS `model_has_roles`;
CREATE TABLE `model_has_roles` (
  `role_id` int(10) unsigned NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  KEY `model_has_roles_model_type_model_id_index` (`model_type`,`model_id`),
  CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of model_has_roles
-- ----------------------------
BEGIN;
INSERT INTO `model_has_roles` VALUES (1, 'App\\Models\\AdminUser', 1);
INSERT INTO `model_has_roles` VALUES (2, 'App\\Models\\AdminUser', 2);
INSERT INTO `model_has_roles` VALUES (3, 'App\\Models\\AdminUser', 3);
INSERT INTO `model_has_roles` VALUES (1, 'App\\Models\\AdminUser', 4);
COMMIT;

-- ----------------------------
-- Table structure for permissions
-- ----------------------------
DROP TABLE IF EXISTS `permissions`;
CREATE TABLE `permissions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `route` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of permissions
-- ----------------------------
BEGIN;
INSERT INTO `permissions` VALUES (1, 'all', 'web', '*', '2018-11-30 07:39:03', '2018-11-30 07:39:03');
INSERT INTO `permissions` VALUES (2, '控制台', 'web', 'home,timeline', '2018-12-03 07:01:37', '2018-12-05 06:37:46');
INSERT INTO `permissions` VALUES (3, '基础权限', 'web', 'home,timeline,admin.login,admin.auth,admin.logout,profile.edit,profile.update,profile.password.edit,profile.password.update', '2018-12-03 07:03:29', '2018-12-05 06:38:04');
INSERT INTO `permissions` VALUES (4, '后台用户', 'web', 'home,timeline,admin.login,admin.auth,admin.logout,admin.index,admin.create,admin.store,admin.edit,admin.update,admin.delete,admin.password.reset,permission.index,permission.create,permission.store,permission.edit,permission.update,permission.delete,role.index,role.create,role.store,role.edit,role.update,role.delete,role.export,profile.edit,profile.update,profile.password.edit,profile.password.update', '2018-12-03 07:03:55', '2018-12-05 06:38:27');
COMMIT;

-- ----------------------------
-- Table structure for role_has_permissions
-- ----------------------------
DROP TABLE IF EXISTS `role_has_permissions`;
CREATE TABLE `role_has_permissions` (
  `permission_id` int(10) unsigned NOT NULL,
  `role_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`role_id`),
  KEY `role_has_permissions_role_id_foreign` (`role_id`),
  CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of role_has_permissions
-- ----------------------------
BEGIN;
INSERT INTO `role_has_permissions` VALUES (1, 1);
INSERT INTO `role_has_permissions` VALUES (2, 2);
INSERT INTO `role_has_permissions` VALUES (3, 2);
INSERT INTO `role_has_permissions` VALUES (2, 3);
INSERT INTO `role_has_permissions` VALUES (3, 3);
COMMIT;

-- ----------------------------
-- Table structure for roles
-- ----------------------------
DROP TABLE IF EXISTS `roles`;
CREATE TABLE `roles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of roles
-- ----------------------------
BEGIN;
INSERT INTO `roles` VALUES (1, 'administrator', 'web', '2018-11-30 07:39:03', '2018-11-30 07:39:03');
INSERT INTO `roles` VALUES (2, '基础权限', 'web', '2018-12-03 07:05:20', '2018-12-05 06:38:58');
INSERT INTO `roles` VALUES (3, '只有控制台权限的角色', 'web', '2018-12-03 07:05:39', '2018-12-03 07:05:39');
COMMIT;

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `avatar` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '頭像',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '郵箱',
  `enable` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否可用 0=停權 1=可用',
  `english_name` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '英文名',
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `last_logined_at` datetime DEFAULT NULL COMMENT '最後登入時間',
  `last_logined_ip` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '最後登入IP',
  `mobile` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '手機號',
  `name` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '姓名',
  `nickname` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '暱稱',
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '密碼',
  `reg_at` datetime DEFAULT NULL COMMENT '注册時間',
  `reg_ip` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '註冊IP',
  `sex` enum('','male','famale') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '性別 0=女 1=男',
  `tel` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '固定電話',
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_mobile_unique` (`mobile`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SET FOREIGN_KEY_CHECKS = 1;
